<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {



    public function login(){
        

        $this->display();
    }



    public function checkdate()
    {
    	// var_dump($_POST);

    	$name=$_POST['username'];
    	$password=md5($_POST['password']);
    	$sql="select * from user where nickname='{$name}'";
    	$res=current(M('user')->query($sql));

    	if ($res['isadmin']==1) {
    		if ($res['password']==$password) {
    			$_SESSION['id']=$res['id'];
		 		$_SESSION['nickname']=$res['nickname'];
		 		$_SESSION['face']=$res['face'];	
				$arr = array(
				'error'=>0,
				'info'=>'登录成功,点击确定即可跳转!'
				);
	    		echo json_encode($arr);
	    		exit;
    		}else{
				$arr = array(
				'error'=>2,
				'info'=>'账号或密码错误,请重新输入！'
				);
	    		echo json_encode($arr);
	    		exit;
    		}
    	}else{
			$arr = array(
			'error'=>1,
			'info'=>'非法操作，该用户不是管理员！'
			);
    		echo json_encode($arr);
    		exit;
    	}

    }
}